package com.thinkTank.oa.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.StringUtil;
import com.thinkTank.oa.base.BaseServiceImpl;
import com.thinkTank.oa.dao.MemoMapper;
import com.thinkTank.oa.entity.Memo;
import com.thinkTank.oa.service.MemoService;

@Transactional
@Service("memoService")
public class MemoServiceImpl extends BaseServiceImpl<Memo> implements MemoService {
	
	private MemoMapper memoMapper;

	@Autowired
	public void setMemoMapper(MemoMapper memoMapper) {
		this.memoMapper = memoMapper;
		setBaseMapper(memoMapper);
	}

	@Override
	public List<Memo> queryAll(Memo t) {
		return memoMapper.queryAll(t);
	}

	@Override
	public void delete(Serializable id) {
		memoMapper.delete(id);
	}

	@Override
	public void update(Memo t) {
		if (StringUtil.isEmpty(t.getPid()) && StringUtil.isEmpty(t.getTaskTime()))
			throw new RuntimeException("id和时间至少有一个");
		memoMapper.update(t);
	}

	@Override
	public Memo getById(Serializable id) {
		return memoMapper.getById(id);
	}

	@Override
	public Integer add(Memo t) {
		return memoMapper.add(t);
	}
	
	@Override
	public void clear(String userId) {
		memoMapper.clear(userId);
	}
}
